package com.cgq.code;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Random;

/**
 * *  Author:陈国强
 * *  Description:生成手机验证码以及缓存时间问题演示
 * *  Date:2023/2/14 10:22
 */
public class PhoneCode {
    public static void main(String[] args) {
//        String phoneCode = getPhoneCode();
//        System.err.println(phoneCode);
    }
    @Autowired
    public RedisTemplate redisTemplate;
    
    /**
     * Description: 每个手机每天只能发送三次，设置过期时间，验证码放到redis中
     * @author: 陈国强
     * @date: 2023/2/14 10:31
     * @params:
     * @return:
     **/
    public static void verifyCode(String phone,String code){
        //1.连接redis
        new RedisTemplate<>();
    }







    
    /**
     * Description: 生成验证码方法类
     * @author: 陈国强
     * @date: 2023/2/14 10:23
     * @params:
     * @return:
     **/
    public static String getPhoneCode() {
        Random random = new Random();
        String code = "";
        for (int i = 0; i < 6; i++) {
            int phoneCode = random.nextInt(10);
            code += phoneCode;
        }
        return code;
    }
}
